package com.sikaryofficial.backend.controller.store;

import cn.hutool.core.text.CharSequenceUtil;
import com.sikaryofficial.backend.domain.dto.req.store.StoreSearchCountReq;
import com.sikaryofficial.backend.manager.store.SearchKeywordManager;
import com.sikaryofficial.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : wuweihong
 * @desc : 搜索相关业务
 * @date : 2025-08-21
 */

@RestController
@RequestMapping("/store/font/v1/search")
@Api(tags = "店铺搜索")
public class StoreSearchController {

    @Autowired
    private SearchKeywordManager searchKeywordManager;

    @PostMapping("/count")
    @ApiOperation(value = "搜索计数")
    public R<Void> searchCount(@RequestBody StoreSearchCountReq req) {
        // 如果搜索关键词为空，则返回空
        if (CharSequenceUtil.isBlank(req.getKeyword())) {
            return R.ok();
        }
        searchKeywordManager.searchCount(req);
        return R.ok();
    }

    @PostMapping("/recommend/top8")
    @ApiOperation(value = "搜索计数")
    public R<Void> recommendTop8() {
        searchKeywordManager.recommendTop8();
        return R.ok();
    }

}
